import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    title: []
  },
  mutations: {
    changeTitle: (state, type) => {
      if (type.type == true) {
        if(!state.title.includes(type.title)){
          state.title.push(type.title)
        }
      } else {
        for (let i = state.title.length - 1; i >= 0; i--) {
          if (type.title == state.title[i]) {
            state.title.splice(i,1)
          }
        }
      }
    }
  },
  getters: {
    getTitle: (state) => {
      return state.title
    }
  },
  actions: {
  },
  modules: {
  }
})
